package com.atguigu.eduteacher.mapper;

import com.atguigu.eduteacher.javabean.EduCourse;
import com.atguigu.eduteacher.javabean.dto.CoursePublishDto;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 课程 Mapper 接口
 * </p>
 *
 * @author author
 * @since 2024-11-21
 */
public interface EduCourseMapper extends BaseMapper<EduCourse> {

    @Select("   SELECT\n" +
            "        c.title, c.cover, c.lesson_num AS lessonNum,\n" +
            "        CONVERT(c.price, DECIMAL(8,2)) AS price,\n" +
            "        s1.title AS subjectLevelOne,\n" +
            "        s2.title AS subjectLevelTwo,\n" +
            "        t.`name` AS teacherName\n" +
            "    FROM\n" +
            "        edu_course c\n" +
            "        LEFT JOIN edu_teacher t ON c.teacher_id = t.id\n" +
            "        LEFT JOIN edu_subject s1 ON c.subject_parent_id = s1.id\n" +
            "        LEFT JOIN edu_subject s2 ON c.subject_id = s2.id\n" +
            "    WHERE\n" +
            "        c.id = #{id}")
    CoursePublishDto selectCoursePublishDtoById(String id);

}
